
// import { BaseParam } from './config.js'
// const { pageUrl, fetchUrl } = BaseParam;
const format = require('string-format')
format.extend(String.prototype)
const baseUrl = process.env.REACT_APP_BASE_URL || '/bcs/api/v1'
const syBaseUrl = process.env.REACT_APP_API_URL || 'https://baas-suzhou-1.cmecloud.cn:31444/order'
// const env = process.env.NODE_ENV || 'stage'; // 当前环境
const pageUrl = process.env.REACT_APP_PAGE_LINK || 'https://baas-order-suzhou-1.cmecloud.cn:31446'

// 苏研的首页跳转
const syHomeLink = process.env.REACT_APP_HOME_LINK || 'https://ecloud.10086.cn:31008'
// 苏研的认证页面
const syCertificate = process.env.REACT_APP_Cert_LINK || 'https://ecloud.10086.cn:31008/usercenter/users/certificate'

// 对接移动云的跳转链接
// const orderLink = `${pageUrl}/order?type={type}`  // 订购页面链接 type: organization 组织     unify 联盟   quorum: quorum
// const renewLink = `${pageUrl}/renew?instanceId={instanceId}&regionId={regionId}` // 续订链接 instanceId 实例id  regionId 资源池id
const orderLink = `${pageUrl}/api/page/op-order-static/product/baas?type={type}` // 订购页面链接 type: organization 组织     unify 联盟   quorum: quorum
const renewLink = `${pageUrl}/api/page/op-order-static/renew/baas?instanceId={instanceId}&regionId={regionId}` // 续订链接 instanceId 实例id  regionId 资源池id

const projectEnv = process.env.REACT_APP_PROJECT_ENV || 'sy' // 苏研 sy 我们自己的测试环境 bcs
export const address = {
  orderLink,
  renewLink,
  syHomeLink,
  syCertificate,
  projectEnv,
  login: `${baseUrl}/user/login`,
  loginApi: {
    getEmailCode: `${baseUrl}/user/login/mail/send`, // 获取邮箱验证码
    verifyCode: `${baseUrl}/user/login/mail`, // 验证验证码
  },
  register: `${baseUrl}/user/register`,
  getPublicKey: `${baseUrl}/pubkey/noauth`, // 获取公钥接口
  logout: `${baseUrl}/user/logout`,
  getPool: `${syBaseUrl}/mop/pool-info`, // 获取资源池 bdp是苏研接口的代理
  bdpApi: {
    operaAuth: `${syBaseUrl}/instances/actions/opera-auth`, // 退订前先校验权限
    instancesCancel: `${syBaseUrl}/instances/actions/cancel`, // 退订
  },
  user: {
    info: `${baseUrl}/user`,
    userList: `${baseUrl}/sub-user`,
    addUser: `${baseUrl}/user/create-sub-user`,
    deleteUser: `${baseUrl}/user/delete-sub-user`,
    updateUser: `${baseUrl}/user/update`,
  },
  log: {
    logList: `${baseUrl}/log/page`,
    userLogList: `${baseUrl}/user/log/page`,
    getLogType: `${baseUrl}/log/type`,
  },
  leagueManagement: {
    leagueList: `${baseUrl}/consortium`,
    createLeague: `${baseUrl}/consortium`,
    deleteLeague: `${baseUrl}/consortium/{consortiumId}`,
    leagueInfo: `${baseUrl}/consortium/{consortiumId}/info`,
    getOrganization: `${baseUrl}/consortium/{consortiumId}/organization`,
    getChannelList: `${baseUrl}/consortium/{consortiumId}/channel/{pageNum}/{pageSize}`,
    getChannelListAll: `${baseUrl}/consortium/{consortiumId}/channel/all`,
    getChannelOrg: `${baseUrl}/consortium/channel/{channelId}/organization/{pageNum}/{pageSize}`,
    getPeerOfCreateChannel: `${baseUrl}/consortium/{consortiumId}/channel/organization/peer-for-create-channel`,
    getPeerOfAddOrg: `${baseUrl}/consortium/{consortiumId}/{channelId}/organization/peer-for-add-channel`,
    getPeerOfInviteOrg: `${baseUrl}/consortium/{consortiumId}/{channelId}/organization/peer-for-invite-channel`,
    createChannel: `${baseUrl}/consortium/channel`,
    addPeerToChannel: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/addorgs`,
    getNodesOfChannel: `${baseUrl}/consortium/{consortiumId}/{channelId}/{peerId}/node/node-for-join-channel`,
    addNodeToOrg: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/addNodes`,
    invitePeerToChannel: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/inviteorg`,
    addNodesOfChannel: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/addNodes`,
    invite: `${baseUrl}/event/invite/{consortiumId}`,
    validateInvite: `${baseUrl}/event/validate/{eventId}`,
    getOrgNodes: `${baseUrl}/organization/{organizationId}/node`,
    getFreeOrg: `${baseUrl}/consortium/organization/{type}`,
    getOrgDatas: `${baseUrl}/consortium/{id}/organization/event/join`,
    inviteJoinLeague: `${baseUrl}/event/apply`,
    joinLeague: `${baseUrl}/event/invite/organization/{eventId}`,
    getAllOrg: `${baseUrl}/organization`,
    applyJoinLeague: `${baseUrl}/event/apply`,
    addCloudPeer: `${baseUrl}/node`,
    orgVoteSet: `${baseUrl}/consortium/{consortiumId}/changestrategy`,
    // applyJoinLeague: '${baseUrl}/consortium/organization`,
    policyList: `${baseUrl}/policy/{consortiumId}/{pageNum}/{pageSize}`,
    createPolicy: `${baseUrl}/policy`,
    updatePolicy: `${baseUrl}/policy`,
    getPolicyOrg: `${baseUrl}/organization/{consortiumId}/policy`,
    getPeerNum: `${baseUrl}/privateData/peerNum`,
    createPrivateData: `${baseUrl}/consortium/{consortiumId}/privateData`, // 创建私有数据集
    deletePrivateData: `${baseUrl}/consortium/{consortiumId}/privateData/{policyId}`, // 创建私有数据集
    getPrivateDataList: `${baseUrl}/consortium/{consortiumId}/privateData`, // 获取私有数据集
    updateLeagueChannel: `${baseUrl}/consortium/config/update`, // 更新系统配置
    updateChannel: `${baseUrl}/channel/config/update`, // 更新通道配置
  },
  chaincode: {
    createChaincode: `${baseUrl}/consortium/chaincode`,
    installChaincode: `${baseUrl}/consortium/chaincode/{chaincodeId}/install`,
    chaincodeList: `${baseUrl}/consortium/{consortiumId}/chaincode/`,
    upload: `${baseUrl}/consortium/chaincode/upload`,
    save: `${baseUrl}/consortium/chaincode/save`,
    chaincodeSubList: `${baseUrl}/consortium/{consortiumId}/chaincode/{name}`,
    peerList: `${baseUrl}/consortium/{consortiumId}/chaincode/{chaincodeId}/node`,
    channelList: `${baseUrl}/consortium/{consortiumId}/chaincode/{chaincodeId}/channel/deploy`,
    upgradeChannelList: `${baseUrl}/consortium/{consortiumId}/chaincode/{chaincodeId}/version/{version}/channel/upgrade`,
    upgrade: `${baseUrl}/consortium/chaincode/{chaincodeId}/{type}`,
    logs: `${baseUrl}/consortium/chaincode/{chaincodeId}/logs`,
    serviceList: `${baseUrl}/service`,
    getPolicy: `${baseUrl}/policy/{consortiumId}`,
    deleteChaincode: `${baseUrl}/consortium/chaincode/{chaincodeId}`,
    compile: `${baseUrl}/chaincode/compile`,
    install: `${baseUrl}/chaincode/debug/install`,
    instantiate: `${baseUrl}/chaincode/debug/instantiate`,
    invoke: `${baseUrl}/chaincode/debug/invoke`,
    query: `${baseUrl}/chaincode/debug/query`,
  },
  fabric: {
    orgsListData: `${baseUrl}/organization`,
    addOrg: `${baseUrl}/organization`,
    leagueListData: `${baseUrl}/consortium`,
    getOrgTypeList: `${baseUrl}/consortium/organization/{orgType}`,
    addLeauge: `${baseUrl}/consortium`,
    deleteLeague: `${baseUrl}/consortium/{consortiumId}`,
    addOrgBare: `${baseUrl}/node/check`,
  },
  organizationManagement: {
    peerList: `${baseUrl}/organization/{id}/user/node`,
    organizationDetail: `${baseUrl}/organization/{id}`,
    certificateList: `${baseUrl}/certificate/{orgId}/{pageNum}/{pageSize}`,
    certificateCreate: `${baseUrl}/certificate`,
    certificateUpdate: `${baseUrl}/certificate/{id}/update`, // 修改证书
    certificateDetail: `${baseUrl}/certificate/{id}`, // 证书详情
    certificateFrozen: `${baseUrl}/certificate/frozen`, // 证书冻结
    certificateUnfrozen: `${baseUrl}/certificate/unfrozen`, // 证书解冻
    download: `${baseUrl}/certificate/{certId}/download`,
    searchCer: `${baseUrl}/certificate/search`,
    monitor: `${baseUrl}/organization/peer/monitor`,
    logs: `${baseUrl}/organization/peer/logs`,
    revokeCert: `${baseUrl}/certificate/revoke`, // 注销证书
    upgrade: `${baseUrl}/organization/{orgId}/resource/update`, // 升级至企业版
    statistic: `${baseUrl}/organization/peer/tx_logs_statistic`, // 节点交易调用统计情况
    blockSpeed: `${baseUrl}/organization/peer/block`, // 查询节点加入的指定通道的交易、区块产生速度
  },
  node: {
    addNode: `${baseUrl}/organization/{orgId}/node`, // 添加节点
    modifyNode: `${baseUrl}/node/modifyCreator`, // 编辑节点
    startNode: `${baseUrl}/organization/{orgId}/node/start`, // 启动节点
    stopNode: `${baseUrl}/organization/{orgId}/node/stop`, // 停止节点
    upgradeNode: `${baseUrl}/organization/{orgId}/node/upgrade`, // 升级节点
    editNodeConfig: `${baseUrl}/organization/{orgId}/node/config`, // 修改节点配置
  },
  applicationService: {
    serviceCenterList: 'https://store-baas.zhigui.com/contract?language=zh',
    getItemServiceDetail: 'https://store-baas.zhigui.com/contract/{contractId}?language=zh',
    myServiceList: `${baseUrl}/service`,
    addService: `${baseUrl}/service`,

  },
  quorumManagement: {
    createQuorumList: `${baseUrl}/mobile/quorum/consortium`,
    getQuorumList: `${baseUrl}/mobile/quorum/consortium`,
    deleteQuorum: '/bcs/api/v1/delete/quorum',
    blockNetwork: {
      networkDetail: `${baseUrl}/mobile/quorum/consortium/{id}`,
      getNodeNum: `${baseUrl}/quorum/explorer/nodenum/{id}`,
      getBlockNum: `${baseUrl}/quorum/explorer/blocknum/{id}`,
      recentBlock: `${baseUrl}/quorum/explorer/blocklist/{id}/{pageIndex}/{pageSize}`,
      recentTx: `${baseUrl}/quorum/explorer/txlist/{id}/{pageIndex}/{pageSize}`,
      itemBlockDetail: `${baseUrl}/quorum/explorer/blockdetail/{id}/{blockId}`,
      itemTxDetail: `${baseUrl}/quorum/explorer/txdetail/{id}/{txId}`,
    },
    peerManagement: {
      peerList: `${baseUrl}/mobile/quorum/node/{id}`,
      itemPeerInfo: `${baseUrl}/mobile/quorum/node/{id}/{peerId}`,
      // itemMonitorInfo: '/bcs/api/v1/quorum/peer/mointor/{id}/detail',
      // itemLogData: '/bcs/api/v1/quorum/peer/log/{id}/detail',
      itemLogData: `${baseUrl}/organization/peer/logs`,
    },
    contractManagement: {
      addChainCodeFile: `${baseUrl}/quorum/contract/upload`,
      addChainCode: `${baseUrl}/quorum/contract`,
      contractList: `${baseUrl}/quorum/{id}/contract`,
      deployChain: `${baseUrl}/quorum/contract/deploy`,
    },
    userManagement: {
      userList: `${baseUrl}/quorum/member/{id}`,
      inviteUser: `${baseUrl}/quorum/invite`,
      checkInvite: `${baseUrl}/quorum/invite/{inviteCode}`,
      getInviteAuthType: `${baseUrl}/quorum/membertype`,
      joinUserInvite: `${baseUrl}/quorum/join`,
      inviteInfo: `${baseUrl}/quorum/inviteinfo/{inviteCode}`,
    },
  },
  event: {
    evenrList: `${baseUrl}/event`,
    eventOperation: `${baseUrl}/event/{eventId}/operation`,
  },
  setting: {
    getBlackList: `${baseUrl}/config/ip-blacklist`,
    getLogSize: `${baseUrl}/config/log-size`,
  },
  monitor: {
    queryOverview: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/browser/board`,
    recentBlock: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/browser/block/{pageNum}/{pageSize}`,
    recentTx: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/browser/transaction/{pageNum}/{pageSize}`,
    queryBlockDetail: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/browser/block/{blockId}`,
    queryTxDetail: `${baseUrl}/consortium/{consortiumId}/channel/{channelId}/browser/transaction/{txId}`,
    queryOrgPeer: `${baseUrl}/consortium/{consortiumId}/browser`,
    queryTxhistory: `${baseUrl}/consortium/{consortiumId}/browser/sevenTxs`,
    searchData: `${baseUrl}/consortium/{consortiumId}/browser/search`,
  },
  common: {
    download: `${baseUrl}/common/download`,
    checkDomain: `${baseUrl}/common/{domain}/exist`,
  },
  license: {
    getStatus: `${baseUrl}/license/status`, // 获取激活状态
    createCode: `${baseUrl}/license/request-code`, // 创建请求码
    activate: `${baseUrl}/license/activate`, // 激活
  },
  resource: {
    getList: `${baseUrl}/resource`, // 获取所有权限列表
    saveMore: `${baseUrl}/resource/batch`, // 保存所有权限
    getDetail: `${baseUrl}/resource/{id}`, // 获取权限详情
  },
  role: {
    createRole: `${baseUrl}/userrole`, // 创建角色
    getRoleDetail: `${baseUrl}/userrole/{id}`, // 获取角色详情
    getList: `${baseUrl}/userrole/page`, // 获取角色列表
    getRoleBindCount: `${baseUrl}/userrole/{id}/count-user`, // 获取角色关联用户数
  },
  permission: {
    create: `${baseUrl}/permission`, // 为角色绑定权限
    update: `${baseUrl}/permission`, // 为角色修改权限
  },
  account: {
    addAccount: `${baseUrl}/user/create-sub-user`, // 添加账户
    updateAccount: `${baseUrl}/user/update-info`, // 修改账户
    accountList: `${baseUrl}/user/list`, // 账户列表
    modifyPwd: `${baseUrl}/user/pwd`, // 修改密码
    delete: `${baseUrl}/user/delete`, // 删除用户
    resetPwd: `${baseUrl}/user/reset-pwd`, // 重置账户密码
    updateStatus: `${baseUrl}/user/update-status`, // 冻结/解冻账户
    detail: `${baseUrl}/user/{id}`, // 账户详情
  },
  check: {
    getList: `${baseUrl}/approving`, // 审核列表
    detail: `${baseUrl}/approving/{id}`, // 审核
    downloadChaincode: `${baseUrl}/approving/download/chaincode`, // 审批链码下载
  },
  crossChain: {
    relayChain: {
      statistic: `${baseUrl}/relay-chain/statistics`,
    },
    contracts: {
      list: `${baseUrl}/cross-chain/contracts`,
    },
    communicationChains: {
      list: `${baseUrl}/cross-chain/communication-chains`,
      operateApplication: `${baseUrl}/cross-chain/communication-chains/{id}/applications/{applicationId}`,
    },
    deployedChannels: `${baseUrl}/cross-chain/channels`,
    applications: {
      list: `${baseUrl}/cross-chain/applications`,
    },
  },
}
